package com.gxa.xiaoucomeshome.controller;

import com.gxa.xiaoucomeshome.service.SlipService;
import com.gxa.xiaoucomeshome.utils.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(value = "SlipController",tags="购物凭条相关的api")
@RestController
@RequestMapping("/slip")
@CrossOrigin
public class SlipController {
    @Autowired
    SlipService slipService;

    @ApiOperation(value = "添加图片")
    @PostMapping("/insert")
    @ApiImplicitParams({@ApiImplicitParam (name = "order_id",value = "订单编号",paramType = "query"),
    @ApiImplicitParam(name = "img",value = "图片1地址",paramType = "query"),
    @ApiImplicitParam(name = "img2",value = "图片2地址",paramType = "query")
    })
    public Map insert(@RequestParam("img") String img,@RequestParam("order_id") String order_id, @RequestParam("img2") String img2){
        slipService.insert(img,order_id,img2);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setMsg("添加成功");
        return jsonResult.getMap();
    }
}
